#pragma once
#include"hash.h"


namespace bit
{
	template<class K,class V>
	class unordered_map
	{
		struct MapOfSet
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename HashBucket::Hash<K, pair<const K, V>, MapOfSet>::iterator iterator;
		typedef typename HashBucket::Hash<K, pair<const K, V>, MapOfSet>::const_iterator const_iterator;
		iterator begin()
		{
			return _hash.begin();
		}
		iterator end()
		{
			return _hash.end();
		}
		pair<iterator,bool> insert(const pair<K, V>& kv)
		{
			return _hash.insert(kv);
		}
		void print()
		{
			_hash.print();
		}
	private:
		HashBucket::Hash<K, pair<const K,V>,MapOfSet> _hash;
	};
	void test_map()
	{
		unordered_map<int, int> hash;
		hash.insert(make_pair(1, 1));
		hash.insert(make_pair(2, 1));
		/*hash.insert(make_pair(3, 1));
		hash.insert(make_pair(33, 1));
		hash.insert(make_pair(4, 1));
		hash.insert(make_pair(5, 1));
		hash.insert(make_pair(6, 1));*/

		//hash.print();
		unordered_map<int, int>::iterator it = hash.begin();
		cout << it->first << " " << it->second << endl;
		unordered_map<int, int>::iterator tit=hash.begin();
		cout << tit->first << " " << tit->second << endl;
		for(auto e:hash)
			cout << e.first << " " << e.second << endl;

	}
}